<template>
  <div class="header-info">
    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">区域设置</el-divider>
      </div>
      <template v-if="screenType==='reportAuto'">
        <el-form-item label="设备类型" label-width="120px">
          <el-select v-model="optionsInfo.reportType" placeholder="请选择设备类型">
            <el-option
                v-for="item in reportTypeOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
      </template>
      <el-form-item label="区域高度" label-width="120px">
        <el-input-number
            :min="0"
            size="small"
            v-model="optionsInfo.headHeight"
        />
      </el-form-item>
      <el-form-item label="弹层倒计时(s)" label-width="120px">
        <el-input-number
            :min="1"
            :max="60"
            :step="1"
            size="small"
            v-model="optionsInfo.layerCountdown"
        />
      </el-form-item>
      <el-form-item label="返回倒计时(s)" label-width="120px">
        <el-input-number
            :min="1"
            :max="120"
            :step="1"
            size="small"
            v-model="optionsInfo.backCountdown"
        />
      </el-form-item>
      <el-form-item label="复诊倒计时(s)" label-width="120px">
        <el-input-number
            :min="1"
            :max="60"
            :step="1"
            size="small"
            v-model="optionsInfo.furtherDoctorCountdown"
        />
      </el-form-item>
      <el-form-item label="文本内容" class="content-screen">
        <el-input
            type="textarea"
            placeholder="请输入内容"
            v-model="optionsInfo.content"
            :autosize="{ minRows: 2, maxRows: 4}"
        />
      </el-form-item>
      <el-form-item label="字体大小">
        <el-input-number
            :min="42"
            :max="70"
            size="small"
            v-model="optionsInfo.fontSize"
        />
      </el-form-item>
      <el-form-item label="字体颜色">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo.fontColor"
        />
      </el-form-item>
    </div>

    <template v-if="false">
      <div class="title-info">
        <el-divider content-position="left">标题</el-divider>
      </div>
      <el-form-item label="标题内容" class="number-area">
        <div class="header-wrap">
          <el-input
              placeholder="请输入内容"
              v-model="optionsInfo.content"
          />
        </div>
      </el-form-item>
      <el-form-item label="标题字号">
        <el-input-number
            :min="12"
            size="small"
            class="hide-spin-button"
            v-model="optionsInfo.fontSize"
        />
      </el-form-item>
      <el-form-item label="标题颜色">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo.fontColor"
        />
      </el-form-item>
    </template>


    <div class="list-item-setting" v-if="routerInfo&&false">
      <div class="title-info">
        <el-divider content-position="left">进程预览</el-divider>
      </div>
      <el-form-item label="进程" class="process-step">
        <div class="header-wrap">
          <div class="title">进程</div>
          <el-button type="primary" size="mini" round @click="()=>handleNext(optionsInfo.step)">
            下一步
          </el-button>
        </div>

        <Steps direction="vertical" :active="optionsInfo.step">
          <Step v-for="(item) in stepOptions" :key="item.time">
            <h3>{{ item.title }}</h3>
            <p>{{ item.time }}</p>
          </Step>
        </Steps>
      </el-form-item>
    </div>
  </div>
</template>

<script>
import {Step, Steps} from 'vant';
import constantDic from "@/utils/vue-i18n/lang/zh-CN";
import updateFormEditor from "@c/public/layer/template/updateFormEditor/index.vue";
import * as types from "@c/public/form-designer/devType/datas-types";

export default {
  name: "reportPickInfoConfig-editor",
  componentName: "reportPickInfoConfig-editor",
  mixins: [],

  components: {
    updateFormEditor,
    Step,
    Steps,
  },

  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
  },

  inject: ['serverFieldList', 'getDesignerConfig'],

  data() {
    return {
      radio: 1,
      screenType: '',
      optionsInfo: Object(),
      constantDic: constantDic,
      predefineColors: types['predefineColors'],
      stepOptions: [
        {
          title: '【报到机】首页',
          time: '2016-07-12 12:40',
        },
        {
          title: '【报到机】状态',
          time: '2016-07-13 12:40',
        }
      ],
      formEditorInfo: {
        info: Object(),
        visible: false
      },
      // 报到机的类型
      reportTypeOptions: [{
        value: 1,
        label: 'R22(R32)'
      }, {
        value: 2,
        label: 'R22A'
      }],
    }
  },

  computed: {
    // 获取报到机所在的路由状态
    routerInfo() {
      const self = this;
      let {params} = (self.$route);
      return params?.type !== 'edit';
    },
  },

  methods: {

    // 下一步
    handleNext() {
      const self = this;
      let {step} = (self.optionsInfo);
      if (++step > 1) {
        this.optionsInfo.step = 0;
      } else {
        this.optionsInfo.step = step;
      }
      this.$store.dispatch('setReportStepInfo', (self.optionsInfo.step));
    },
  },


  watch: {
    // 组件的所有信息
    selectedWidget: {
      handler: function (val) {
        this.screenType = (val.screenDataType);
      },
      deep: true,
      immediate: true
    },

    // 组件的所有信息
    optionModel: {
      handler: function (val) {
        this.optionsInfo = val[val.config];
      },
      deep: true,
      immediate: true
    }
  }

}
</script>


<style lang="scss" scoped>
.process-step {
  display: flex;
  flex-direction: column;

  :deep(.el-form-item__label) {
    display: none;
    width: 100% !important;
  }

  :deep(.el-form-item__content) {
    margin-left: 0 !important;;
  }

  .header-wrap {
    display: flex;
    justify-content: space-between;
    margin-bottom: 14px;
    align-self: center;
    align-items: center;

    .title {
      @include fontWeight();
      font-size: 20px;
    }

    .el-button {
      padding: 8px 22px
    }
  }

}

.number-area,
.tips-area {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-bottom: 14px;
  align-self: center;
  align-items: center;

  :deep(.el-form-item__label) {
    width: 100% !important;
    @include fontWeight();
  }

  :deep(.el-form-item__content) {
    width: 100% !important;
    margin-left: 0 !important;
  }
}

.content-screen {
  display: flex;
  flex-direction: column;

  :deep(.el-form-item__label) {
    width: 100% !important;
    font-weight: bolder;
  }

  :deep(.el-form-item__content) {
    margin-left: 0 !important;

    .el-textarea__inner {
      line-height: 34px;
    }
  }
}

</style>